package com.baaio.properties;

import java.io.InputStream;
import java.text.MessageFormat;
import java.util.Properties;
/**
 * 数据库配置属性文件解析类<br>
 * @author baaio
 *
 */
public class DriverItem
{

	private static InputStream is = null;
	private static Properties pp = null;
	private final static String fielName = "DriverURl.properties";

	public static String getJDBCUrl(String dbHost, String dbPort,
			String dbName, String sqlType)
	{

		return MessageFormat.format(getProperty(sqlType), dbHost, dbPort,
				dbName);
	}

	private static String getProperty(String sqlType)
	{

		try
		{
			is = DriverItem.class.getClassLoader()
					.getResourceAsStream(fielName);
			pp = new Properties();
			pp.load(is);
			is.close();
		}
		catch (Exception e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return pp.getProperty(sqlType);
	}

	public static String getDriverName(String sqlType)
	{

		return getProperty(sqlType + "Driver");
	}

}
